<template>
  <div class="layout">
    <el-container style="height: 100%">
      <el-aside class="aside" width="auto">
        <Aside :isCollapse="isCollapse"></Aside>
      </el-aside>
      <el-container>
        <el-header>
          <Header @toggle="menuCollapse"></Header>
        </el-header>
        <el-main>
          <Breakcrum :crumData="crumInfo"></Breakcrum>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Aside from "../components/Menu.vue";
import Header from "../components/Header.vue";
import Breakcrum from "../components/Breakcrum.vue";
export default {
  name: "app",
  data() {
    return {
      isCollapse: false
    };
  },
  components: {
    Aside,
    Header,
    Breakcrum
  },
  computed: {
    crumInfo: function() {
      const crumData = this.$route.matched;
      const crumArr = crumData.map(v => {
        return { path: v.path, name: v.meta };
      });
      return crumArr;
    }
  },
  methods: {
    menuCollapse: function() {
      this.isCollapse = !this.isCollapse;
    }
  }
};
</script>

<style>
.layout {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

.aside {
  height: 100%;
}

.el-header {
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}

.el-main {
  background-color: rgb(233, 238, 243);
}
</style>
